package com.ybliang.plat.cms.feign.fallback;

import com.ybliang.plat.cms.feign.UserFeignClient;
import com.ybliang.plat.common.data.vo.resp.Resp;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        String message = "fallback:" + throwable.getMessage();
        return new UserFeignClient() {

            @Override
            public Resp info() {
                return Resp.success(message);
            }

            @Override
            public Resp findByMobile(String mobile) {
                return Resp.success(message);
            }
        };
    }
}
